package user

import (
	"time"
)

// User 用户实体
type User struct {
	ID        string    `bson:"_id,omitempty"`
	Username  string    `bson:"username"`
	Password  string    `bson:"password"`
	Email     string    `bson:"email"`
	CreatedAt time.Time `bson:"created_at"`
	UpdatedAt time.Time `bson:"updated_at"`
}

// NewUser 创建新用户
func NewUser(username, password, email string) *User {
	now := time.Now()
	return &User{
		Username:  username,
		Password:  password,
		Email:     email,
		CreatedAt: now,
		UpdatedAt: now,
	}
}

// Update 更新用户信息
func (u *User) Update(username, email string) {
	u.Username = username
	u.Email = email
	u.UpdatedAt = time.Now()
}